home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / clang / c_course.zip / LIST.C < prev    next >
Text File  |  1989-12-30  |  2KB  |  33 lines

  1. /* *************************************************************** */
  2. /* This program will read in any text file and list it on the      */
  3. /* monitor with line numbers and with page numbers.                */
  4. /* *************************************************************** */
  5.  
  6. #include "stdio.h"                     /* standard I/O header file */
  7. #define MAXCHARS 255                     /* maximum size of a line */
  8. FILE *file_point;                    /* pointer to file to be read */
  9. FILE *print_file_point;                      /* pointer to pronter */
  10. char oneline[256];                     /* input string buffer area */
  11.  
  12. main(number,name)
  13. int number;                 /* number of arguments on command line */
  14. char *name[];               /* arguments on the command line       */
  15. {
  16. char *c;                       /* variable to indicate end of file */
  17. char *point;
  18.  
  19.    point = name[1];
  20.    open_file(number,point);     /* open the file to read and print */
  21.    open_print_file();
  22.  
  23.    do {
  24.       c = fgets(oneline,MAXCHARS,file_point);     /* read one line */
  25.       if (c != NULL)
  26.          print_a_line();                         /* print the line */
  27.    } while (c != NULL);                      /* continue until EOF */
  28.  
  29.    top_of_page();                     /* move paper to top of page */
  30.    close(file_point);                           /* close read file */
  31.    close(print_file_point);                  /* close printer file */
  32. }
  33.